<template>
  <div class="good-item" @click="itemClick">
    <img :src="showimage" alt="" />
    <div class="goods-info">
      <p>{{ goodsItem.title }}</p>
      <span class="price">${{ goodsItem.price }}</span>
      <span class="cfav">{{ goodsItem.cfav }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "GoodsListItem",
  props: {
    goodsItem: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  computed: {
    showimage() {
      return (
        /* this.goodsItem.show.image || */
        this.goodsItem.show.img || this.goodsItem.show.img
      );
    },
  },
  methods: {
    itemClick() {
      this.$router.push("/detail/" + this.goodsItem.iid);
      console.log(this.goodsItem.iid + "测试");
      console.log(this.goodsItem.show.img);
    },
  },
};
</script>

<style>
.good-item {
  width: 47%;
  box-sizing: border-box;
  margin-top: 20px;
  margin-bottom: 20px;
  font-size: 10px;
}
.good-item img {
  width: 100%;
  height: 100%;
  border-radius: 5px;
}
.goods-info p {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.price,
.cfav {
  padding: 20px;
}
.price {
  color: red;
}
.goods-info {
  position: relative;
}
.cfav::before {
  content: "";
  position: absolute;
  left: 93px;
  top: 18px;
  width: 15px;
  height: 15px;
  background: url(../../../assets/img/common/collect.svg) 0 0/14px 14px;
}
</style>